package view;

import java.awt.Rectangle;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import model.donnee.Bio;
import model.donnee.MembreExecutif;

public class ConsultationMembreExecutif extends JFrame {
	private final int largeurFrame = 600;
	private final int hauteurFrame = 600;
	
	private JLabel lblNom = new JLabel("Nom : ");
	private JLabel lblDateNaissance = new JLabel("Date de naissance : ");
	private JLabel lblLieuNaissance = new JLabel("Lieu de naissance : ");
	private JLabel lblBiographie= new JLabel("Biographie : ");
	
	private JTextField txtNom = new JTextField();
	private JTextField txtDateNaissance = new JTextField();
	private JTextField txtLieuNaissance = new JTextField();
	private JTextArea txtBiographie = new JTextArea();
	
	private JScrollPane scrollBio = new JScrollPane();
	
	public ConsultationMembreExecutif(MembreExecutif membreExecutif) {
		this.setTitle("");
		this.setBounds(new Rectangle(largeurFrame,hauteurFrame));
		
		this.lblNom.setBounds(new Rectangle(3,10,150,20));
		this.lblDateNaissance.setBounds(new Rectangle(3,30,150,20));
		this.lblLieuNaissance.setBounds(new Rectangle(3,50,150,20));
		this.lblBiographie.setBounds(new Rectangle(3,70,150,20));
		
		this.txtNom.setBounds(new Rectangle(163,10,350,20));
		this.txtDateNaissance.setBounds(new Rectangle(163,30,350,20));
		this.txtLieuNaissance.setBounds(new Rectangle(163,50,350,20));
		this.txtBiographie.setBounds(new Rectangle(3,90,500,400));
		this.scrollBio.setBounds(new Rectangle(3,90,500,400));
		
		this.txtBiographie.setLineWrap(true);
		this.txtBiographie.setEditable(false);
		this.scrollBio.setViewportView(txtBiographie);
		
		this.txtNom.setEditable(false);
		this.txtDateNaissance.setEditable(false);
		this.txtLieuNaissance.setEditable(false);

		this.txtNom.setText(membreExecutif.getPersonne().getNom() +", "+membreExecutif.getPersonne().getPrenom());
		this.txtDateNaissance.setText(membreExecutif.getPersonne().getDatedenaissance());
		this.txtLieuNaissance.setText(membreExecutif.getPersonne().getLieunaissance());
		
		this.scrollBio.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		this.scrollBio.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		
		String textBio = "";
		if (membreExecutif.getbio() != null) {
			Bio next = membreExecutif.getbio();
			textBio += next.getLiteralString();
			
			while (next.getBioNext() != null) {
				next = next.getBioNext();
				textBio += next.getLiteralString();
			}
		}
		
		this.txtBiographie.setText(textBio);
		
		
		this.add(this.lblNom);
		this.add(this.lblDateNaissance);
		this.add(this.lblLieuNaissance);
		this.add(this.lblBiographie);
		
		this.add(this.txtNom);
		this.add(this.txtDateNaissance);
		this.add(this.txtLieuNaissance);
		this.add(this.scrollBio);
		
		this.add(new JLabel());
		this.setVisible(true);
	}

}
